package com.myz.service.feign.feign;

import feign.FeignException;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@Component
public class ScheduleUploadServiceFallbackFactory implements FallbackFactory<ScheduleUploadService> {

    @Override
    public ScheduleUploadService create(Throwable cause) {
        if (cause instanceof FeignException) {
            FeignException feign = (FeignException) cause;
            System.out.println("_______________________________");
        }
        return new ScheduleUploadService() {

            @Override
            public String handleFileUpload(MultipartFile file) {
                log.error("ScheduleUploadServiceFallbackFactory error:", cause);

                return "ScheduleUploadService FallbackFactory";
            }
        };
    }
}
